package cn.tedu.csmall.product.config;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;

@Configuration
public class ValidationConfiguration {


    @Bean
    public javax.validation.Validator v(){
        return Validation.byProvider(HibernateValidator.class)
                .configure()  //开始配置
                .failFast(true)   //配置快速失败
                .buildValidatorFactory()  //构建Validator工厂
                .getValidator();  //从工厂中获取Validator对象
    }

}
